package utils;

import exttable.SGTTestParametrs;
import exttable.view.ILocalsation;

import java.util.Locale;
import java.util.ResourceBundle;

/**
 * Created by IntelliJ IDEA.
 * User: Admin
 * Date: Feb 5, 2010
 * Time: 10:42:25 PM
 * To change this template use File | Settings | File Templates.
 */
public class Localisation implements java.io.Serializable  {

    public static String getMessage(String key) {
        ResourceBundle rb = ResourceBundle.getBundle("messages.msg", SGTTestParametrs.getInstance().getLocale());
        return rb.getString(key);
    }

    public static String getMessage(String key, ELocale locale) {
        ResourceBundle rb = ResourceBundle.getBundle("messages.msg", new Locale(locale.getLocaleCode()));
        return rb.getString(key);
    }

    public static <T extends ILocalsation> String getMsg(ILocalsation value) {
        switch (SGTTestParametrs.getInstance().getCurrentLocal()) {

            case RU:
                return value.getNameRu() == null ? "NO DATA" : value.getNameRu();
            case EN:
                return value.getNameEn() == null ? "NO DATA" : value.getNameEn();
            case KZ:
                return value.getNameKz() == null ? "NO DATA" : value.getNameKz();
            default:
                throw new IllegalArgumentException("no such language");
        }
    }

}
